package com.oneday.nuo.base.common;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oneday.nuo.base.entity.NuoUserEntity;
import com.oneday.nuo.base.exception.NuoException;
import com.oneday.nuo.base.response.NuoErrorStatus;

import java.util.List;

public class NuoUtil {

    public static final int YES = 1;
    public static final int NOT = 0;

    public static final int DEFAULT_SORT = 0;

    /**
     * 判断是不是null
     * @Author: liushuai
     * @Date: 2021/3/18 20:19
     * @param : * @param error
     * @param value
     * @return :void
     **/
    public static void isNotNull(String error, String value){
        if(StrUtil.isBlank(value)){
            throw  new NuoException(error);
        }
    }


    public static IPage convertPage(Class<?> type, IPage page){
        List<Object> records = page.getRecords();
        List<?> list = Convert.toList((Class<?>) type, records);
        IPage iPage = new Page<>();
        iPage.setRecords(list);
        iPage.setTotal(page.getTotal());
        return  iPage;
    }



}
